//PlayerOwner.SelectedVeterancy = VetType;   serverst
//BroadcastLocalizedMessage
//		if ( CurrentGame!=None && CurrentGame.EndGameType > 0 )
		//{ConsoleCommand("get ini:Engine.Engine.ViewportManager Bloom"))
//			DrawEndGameHUD(C, (CurrentGame.EndGameType==2
	//local KFGameReplicationInfo CurrentGame;
	//CurrentGame = KFGameReplicationInfo(Level.GRI);
	//InvasionGameReplicationInfo(GameReplicationInfo).WaveNumber
	//KFMonster(C.Pawn).SetBossLaught()
	//GameReplicationInfo.bMatchHasBegun = true;
	/*GameInfo *
function DiscardInventory( Pawn Other )
{
    Other.Weapon = None;
    Other.SelectedItem = None;
    while ( Other.Inventory != None )
        Other.Inventory.Destroy();
}
	Called when pawn has a chance to pick Item up (i.e. when
   the pawn touches a weapon pickup). Should return true if
   he wants to pick it up, false if he does not want it.
*/
//function bool PickupQuery( Pawn Other, Pickup item )
class FConsole extends Mutator Config(FConsole);

var config string PlayerID1,PlayerID2,PlayerID3,PlayerID4,PlayerID5,PlayerID6,PlayerID7;
var config string PlayerID8,PlayerID9,PlayerID10;

event PreBeginPlay()
{
	//Spawn(Class'PerksSimHostOrg.ChatLog');
}

function Mutate(string InputString, PlayerController Sender)
{
	local string Command;
	local string Parametr;
	local KFGameReplicationInfo CurrentGame;
	CurrentGame = KFGameReplicationInfo(Level.GRI);

	if(Sender.PlayerReplicationInfo.bAdmin)
	{
		Divide(InputString," ", Command, Parametr);
		if( Command ~= "S" )
		{
			Summon(Parametr,Sender,false);
		}
		if( Command ~= "S0" )
		{
			Summon(Parametr,Sender,true);
		}
		if( Command ~= "CW" )
		{
			ChangeWave(Parametr);
		}
/* 		if( InputString ~= "LA" )
		{
			KFMonster(Sender.Pawn).SetBossLaught();
		} */
		if( Command ~= "R" )
		{
			Resurrect(Parametr);
		}
		if( InputString ~= "RA" )
		{
			ResurrectAll();
		}
		if( Command ~= "CVm" )
		{
			ChangeVeterancyM(Parametr);
		}
		if( Command ~= "CVb" )
		{
			ChangeVeterancyB(Parametr);
		}
		if( Command ~= "CVsp" )
		{
			ChangeVeterancySP(Parametr);
		}
		if( Command ~= "CVss" )
		{
			ChangeVeterancySS(Parametr);
		}
		if( Command ~= "CVcm" )
		{
			ChangeVeterancyCM(Parametr);
		}
		if( Command ~= "CVf" )
		{
			ChangeVeterancyF(Parametr);
		}
		if( Command ~= "CVdm" )
		{
			ChangeVeterancyDM(Parametr);
		}
		if( InputString ~= "GT" )
		{
 			Level.Game.bGameEnded = false;
/* 			Level.Game.bOverTime = false;
			Level.Game.bWaitingToStartMatch = true;
			Level.Game.InitGameReplicationInfo();
			Level.Game.InitVoiceReplicationInfo();  */
			CurrentGame.EndGameType=0;
			//Level.Game.Reset();
		}
		if( InputString ~= "GT2" )
		{
			CurrentGame.EndGameType=1;
			Level.Game.bGameEnded=false;
		}
		if( InputString ~= "GT3" )
		{
			CurrentGame.EndGameType=2;
			Level.Game.bGameEnded=false;
		}
		if( Command ~= "Vel" )
		{
			ModifyVelocity(Parametr);

		}
		if( Command ~= "KP" )
		{
			KillPlayer(Parametr);
		}
		if( InputString ~= "KPAll" )
		{
			KillAllPlayers();
		}

	}
	if( InputString ~= "KillAll" )
	{
		KillAll();
	}
	if(NextMutator!=none)
		NextMutator.Mutate(InputString, Sender); 
}

function ChangeVeterancyM(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetFieldMedic',-1);
			//Log(C.SelectedVeterancy);
				// if ( lb_PerkSelect.GetIndex()>=0 && S!=None )
		// S.ServerSelectPerk(S.CachePerks[lb_PerkSelect.GetIndex()].PerkClass);
		}
	}
} 

function ChangeVeterancyB(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetBerserker',-1);
		}
	}
}

function ChangeVeterancySP(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetSupportSpec',-1);
		}
	}
}

function ChangeVeterancySS(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetSharpshooter',-1);
		}
	}
}

function ChangeVeterancyCM(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetCommando',-1);
		}
	}
}

function ChangeVeterancyF(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetFirebug',-1);
		}
	}
}

function ChangeVeterancyDM(string PlayerToken)
{
	local Controller C;
	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			ServerStStats(KFPCServ(C).SteamStatsAndAchievements).ForceServerSelectPerk(class'SRVetDemolitions',-1);
		}
	}
}

function ModifyVelocity(string PlayerToken)
{
	//local KFPlayerController KFPC;
	local Controller C;

	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			C.Pawn.Spawn(Class'VelocityWCard');
		}
	}
} 

function KillAll()
{
	local KFMonster zombie;
	if(KFGameReplicationInfo(Level.Game.GameReplicationInfo).MaxMonsters>4)
		return;
	foreach DynamicActors(class'KFMonster', zombie)
	{
		if( ExZombieBoss(zombie)==none && ZombieBoss(zombie)==none &&
			ZombieFleshPound(zombie)==none && ZombieMeatPounder(zombie)==none &&
			ZombieMauler(zombie)==none && ZombieScrake(zombie)==none
			)
		{
			zombie.TakeDamage(300000, Instigator, Location, vect(0,0,0), class'DamTypeM99W');
		}
	}
}

function Resurrect(string PlayerToken)
{
	local KFPlayerController KFPC;
	local Controller C;

	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			KFPC=KFPlayerController(C);
			KFPC.PlayerReplicationInfo.Score = Max(KFGameType(Level.Game).MinRespawnCash, int(KFPC.PlayerReplicationInfo.Score));
			KFPC.SetViewTarget(C);
			KFPC.ClientSetBehindView(false);
			KFPC.bBehindView = false;
			KFPC.bSpawnedThisWave = false;
			KFPC.bReadyToStart = true;
			KFPC.ClientSetViewTarget(KFPC.Pawn);
			KFPC.PlayerReplicationInfo.bOutOfLives = false;
			KFPC.PlayerReplicationInfo.bOnlySpectator = false;
			KFPC.Pawn = none;
			SRGameType(Level.Game).TotalPlayerRestart(KFPC);
		}
	}
}

function ResurrectAll()
{
	local KFPlayerController KFPC;
	local Controller C;

	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && C.Pawn.Health<=0 && !C.PlayerReplicationInfo.bOnlySpectator)
		{
			KFPC=KFPlayerController(C);
			KFPC.PlayerReplicationInfo.Score = Max(KFGameType(Level.Game).MinRespawnCash, int(KFPC.PlayerReplicationInfo.Score));
			KFPC.SetViewTarget(C);
			KFPC.ClientSetBehindView(false);
			KFPC.bBehindView = false;
			KFPC.bSpawnedThisWave = false;
			KFPC.bReadyToStart = true;
			KFPC.ClientSetViewTarget(KFPC.Pawn);
			KFPC.PlayerReplicationInfo.bOutOfLives = false;
			KFPC.PlayerReplicationInfo.bOnlySpectator = false;
			KFPC.Pawn = none;
			SRGameType(Level.Game).TotalPlayerRestart(KFPC);
		}
	}
}

function KillPlayer(string PlayerToken)
{
	//local KFPlayerController KFPC;
	local Controller C;

	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && string(C.PlayerReplicationInfo.PlayerID)~=PlayerToken)
		{
			C.Pawn.TakeDamage(300000, Instigator, Location, vect(0,0,0), class'DamTypeM99W');
		}
	}
}

function KillAllPlayers()
{
	//local KFPlayerController KFPC;
	local Controller C;

	for( C = Level.ControllerList; C != None; C = C.nextController ) 
	{
		if( C.IsA('PlayerController') && C.Pawn.Health>0 && !C.PlayerReplicationInfo.bAdmin)
		{
			C.Pawn.TakeDamage(300000, Instigator, Location, vect(0,0,0), class'DamTypeM99W');
		}
	}
}


function Summon(string param, Controller C, bool ifZero)
{
	local class<actor> NewClass;
	local vector SpawnLoc;
	local string ClassName;
	if(param=="1")
	{
		ClassName="PerksSimHostOrg.ColtWPickUp";
	}
	if(param=="2")
	{
		ClassName="PerksSimHostOrg.SFlameThrowerWPickup";
	}
	if(param=="3")
	{
		ClassName="PerksSimHostOrg.MG34WPickup";
	}
	if(param=="4")
	{
		ClassName="KFChar.ZombieHusk";
	}
	if(param=="5")
	{
		ClassName="PerksSimHostOrg.SVDWPickUp";
	}
	if(param=="6")
	{
		//ClassName="PerksSimHostOrg.GaussRifleWPickup";
	}
	if(param=="7")
	{
	}
	if(param=="8")
	{
	}
	if(param=="9")
	{
		ClassName="PerksSimHostOrg.ZombieBroodling";
	}
	if(param=="0")
	{
	}
	
	NewClass = class<actor>( DynamicLoadObject( ClassName, class'Class' ) );
	if( NewClass!=None )
	{
		if ( C.Pawn != None )
		{
			//Log("mutate Pawn Location="$C.Pawn.Location);
			if(ifZero)
				SpawnLoc=Location;
			else
				SpawnLoc = C.Pawn.Location;
		}
		else
		{
			//Log("mutate Location="$C.Location);
			if(ifZero)
				SpawnLoc=Location;
			else
				SpawnLoc = C.Location;
		}
		Spawn( NewClass,,,SpawnLoc + 72 * Vector(Rotation) + vect(0,0,1) * 15 );
	}
}

function ChangeWave(string waveN)
{
	local KFGameReplicationInfo CurrentGame;
	local int wN;
	CurrentGame = KFGameReplicationInfo(Level.GRI);
	wN=int(waveN);
	CurrentGame.WaveNumber=wN-1;
	SRGameType(Level.Game).WaveNum=wN-1;
}

defaultproperties
{
     GroupName="FConsole"
     FriendlyName="FConsole"
     Description="Console Extension"
}
